﻿<script type="text/javascript">
    $.parser.onComplete = function () {

        $("#peibidan_shuiwenliao_zhandian").combobox({
            url: 'json/zhandian.json',
            method: 'get',
            valueField: 'zhandian',
            textField: 'zhandian',
            panelWidth: 200,
            panelHeight: 'auto',
            editable: false,
            onLoadSuccess: function () {
                $("#peibidan_shuiwenliao").datagrid({
                    url: "handler/xinxi_peibidan.ashx",
                    method: "post",
                    queryParams: {
                        requestType: '1',
                        uid: window.uid,
                        kid: window.kid,
                        zhandian: $("#peibidan_shuiwenliao_zhandian").combobox('getText'),
                        mingcheng: $("#peibidan_shuiwenliao_mingcheng").textbox('getText'),
                        leixing:'水稳料'
                    },
                    height: document.body.scrollHeight - 180,
                    onLoadSuccess: function (data) {
                        $(this).datagrid('autoMergeCells', ["mingcheng"]);
                    }
                });
            }
        });

        $("#info_peibidan_shuiwenliao_zhandian").combobox({
            url: 'json/zhandian.json',
            method: 'get',
            valueField: 'zhandian',
            textField: 'zhandian',
            panelWidth: 200,
            panelHeight: 'auto',
            editable: false,
            loadFilter: function (data) {
                var returnData = [];
                for (var i = 0; i < data.length; i++)
                {
                    if (data[i].zhandian != "—全部—")
                    {
                        returnData.push(data[i]);
                    }
                }
                return returnData;
            }
        });

        $("#info_peibidan_shuiwenliao_wuliao").combobox({
            url: 'handler/xinxi_zidian.ashx',
            method: 'post',
            queryParams: {
                uid: window.uid,
                kid: window.kid,
                ziDianType: '4',
                fenZu: '水稳料'
            },
            valueField: 'id',
            textField: 'xinghao',
            panelWidth: 200,
            panelHeight: 'auto',
            editable: false
        });

    }

    var toolbar_peibidan_shuiwenliao = [{
        text: '新增配比单',
        iconCls: 'icon-add',
        handler: function () {
            $("#info_peibidan_shuiwenliao_mingcheng").textbox('setValue', '');
            $("#info_peibidan_shuiwenliao_peibi").textbox('setValue', '');
            $("#info_peibidan_shuiwenliao_wuliao").combobox('setValue','');
            $("#shuiwenliaopeibidanid").val('');
            $("#peibidan_shuiwenliao_edit").dialog('open');
        }
    }, '-', {
        text: '修改',
        iconCls: 'icon-edit',
        handler: function () {
            var curRow = $("#peibidan_shuiwenliao").datagrid('getSelected');
            if (curRow) {
                $("#shuiwenliaopeibidanid").val(curRow.id);
                $("#info_peibidan_shuiwenliao_zhandian").combobox('setValue', curRow.zhandian);
                $("#info_peibidan_shuiwenliao_mingcheng").textbox('setValue', curRow.mingcheng);
                $("#info_peibidan_shuiwenliao_wuliao").combobox('setValue', curRow.guanlianbianhao);
                $("#info_peibidan_shuiwenliao_peibi").textbox('setValue', curRow.peibi);
                $("#peibidan_shuiwenliao_edit").dialog('open');
            }
            else {
                alert("请选择要修改的配合比信息。");
            }
        }
    }, '-', {
        text: '删除',
        iconCls: 'icon-remove',
        handler: function () {
            $("#peibidan_shuiwenliao_dlg").dialog('open');
        }
    }];

    function submitShuiWenLiaoPeiBiDan()
    {
        var peibidanid = $("#shuiwenliaopeibidanid").val();
        var zhandian = $("#info_peibidan_shuiwenliao_zhandian").combobox('getText');
        var mingcheng = $("#info_peibidan_shuiwenliao_mingcheng").combobox('getText');
        var peibiwuliao = $('#info_peibidan_shuiwenliao_wuliao').combobox('getText');
        var guanlianbianhao = $("#info_peibidan_shuiwenliao_wuliao").combobox('getValue');
        var peibi = $('#info_peibidan_shuiwenliao_peibi').textbox('getText');
        if (zhandian && mingcheng && peibiwuliao && guanlianbianhao && peibi) {
            $.post('handler/xinxi_peibidan.ashx', { requestType: '2', uid: window.uid, kid: window.kid, peibidanid:peibidanid,zhandian:zhandian,mingcheng:mingcheng,peibiwuliao:peibiwuliao,guanlianbianhao:guanlianbianhao,peibi:peibi,leixing:'水稳料'}, function (data, status) {
                if (data == "OK") {
                    $("#peibidan_shuiwenliao").datagrid('load', {
                        requestType: '1',
                        uid: window.uid,
                        kid: window.kid,
                        zhandian: $("#peibidan_shuiwenliao_zhandian").combobox('getText'),
                        mingcheng: $("#peibidan_shuiwenliao_mingcheng").textbox('getText'),
                        leixing: '水稳料'
                    });
                    alert('保存成功。');
                    return;
                }
                if (data == "Failed") {
                    alert("新增水稳料配比单信息失败，请重试");
                    return;
                }
                alert(data);
                $("#peibidan_shuiwenliao_edit").dialog('close');
            });
        }
        else {
            alert("信息不完整，请检查后重试...");
        }
    }

    function delShuiWenLiaoPeiBiDan() {
        var curRow = $("#peibidan_shuiwenliao").datagrid('getSelected');
        if (curRow) {
            $.post('handler/xinxi_peibidan.ashx', { requestType: "3", peibidanid: curRow.id, uid: window.uid, kid: window.kid }, function (data, status) {
                if (data == "OK") {
                    $("#peibidan_shuiwenliao_dlg").dialog('close');
                    $("#peibidan_shuiwenliao").datagrid('load', {
                        requestType: '1',
                        uid: window.uid,
                        kid: window.kid,
                        zhandian: $("#peibidan_shuiwenliao_zhandian").combobox('getText'),
                        mingcheng: $("#peibidan_shuiwenliao_mingcheng").textbox('getText'),
                        leixing:'水稳料'
                    });
                    return;
                }
                if (data == "Failed") {
                    alert("删除水稳料配比单信息失败，请重试");
                    $("#peibidan_shuiwenliao_dlg").dialog('close');
                    return;
                }
                alert(data);
                $("#peibidan_shuiwenliao_dlg").dialog('close');
            });
        }
        else {
            alert("请选择要删除的配合单信息。");
        }
    }

    function clearShuiWenLiaoPeiBiDan()
    {
        $("#peibidan_shuiwenliao_edit").dialog('close');
    }

    $("#peibidan_shuiwenliao_chaxun").click(function () {
        //查询
        $("#peibidan_shuiwenliao").datagrid('load', {
            requestType: '1',
            uid: window.uid,
            kid: window.kid,
            zhandian: $("#peibidan_shuiwenliao_zhandian").combobox('getText'),
            mingcheng: $("#peibidan_shuiwenliao_mingcheng").textbox('getText'),
            leixing:'水稳料'
        });
    });

</script>

<div class="easyui-panel" data-options="height:90,border:false" title="数据检索" style="border-top-width: 0px;
    border-bottom-width: 1px; padding: 15px; width:100%">
    <table style="font-size: 12px;">
        <tr>
            <td>
                站点：
            </td>
            <td>
                <input name="peibidan_shuiwenliao_zhandian" id="peibidan_shuiwenliao_zhandian" style="width: 175px;" />
            </td>
            <td>
                配比单名称：
            </td>
            <td>
                <input class="easyui-textbox" name="peibidan_shuiwenliao_mingcheng" id="peibidan_shuiwenliao_mingcheng" style="width: 175px;" />
            </td>
            <td>
                <a id="peibidan_shuiwenliao_chaxun" class="easyui-linkbutton" data-options="iconCls:'icon-search'"
                   style="width: 60px; margin-left: 20px;">查询</a>
            </td>
        </tr>
    </table>
</div>

<table id="peibidan_shuiwenliao" style="width:100%" title="水稳料配比单" class="easyui-datagrid" data-options="border: false, singleSelect: true, collapsible: false, striped: true, toolbar: toolbar_peibidan_shuiwenliao">
    <thead>
        <tr>
            <th data-options="field:'mingcheng',width:150">
                配比单名称
            </th>
            <th data-options="field:'guanlianwuliao',width:170">
                配比物料
            </th>
            <th data-options="field:'peibi',width:100">
                配比(%)
            </th>
            <th data-options="field:'id',hidden:true">
                编号
            </th>
        </tr>
    </thead>
</table>

<div id="peibidan_shuiwenliao_edit" class="easyui-dialog" title="水稳料配比单信息编辑" data-options="modal:true,closed:true,iconCls:'icon-edit',draggable:false,collapsible:false,minimizable:false,maximizable:false,resizable:false"
     style="width: 500px; height: 300px; padding: 10px;">
    <div style="width: 350px; margin: 0 auto;">
        <table cellpadding="5" style="font-size: 13px; margin: 0 auto; padding-top: 20px">
            <tr>
                <td>
                    站点：
                </td>
                <td>
                    <input class="easyui-combobox" name="info_peibidan_shuiwenliao_zhandian" id="info_peibidan_shuiwenliao_zhandian" style="width: 200px;" />
                </td>
            </tr>
            <tr>
                <td>
                    配比单名称：
                </td>
                <td>
                    <input class="easyui-textbox" name="info_peibidan_shuiwenliao_mingcheng" id="info_peibidan_shuiwenliao_mingcheng" data-options="width:200, panelHeight: 'auto',editable:true,valueField:'xiangmu',textField:'xiangmu'">
                    </input>
                </td>
            </tr>
            <tr>
                <td>
                    配比材料:
                </td>
                <td>
                    <input class="easyui-combobox" type="text" id="info_peibidan_shuiwenliao_wuliao" name="info_peibidan_shuiwenliao_wuliao"
                           data-options="width:200"></input>
                </td>
            </tr>
            <tr>
                <td>
                    配比(%):
                </td>
                <td>
                    <input class="easyui-textbox" type="text" id="info_peibidan_shuiwenliao_peibi" name="info_peibidan_shuiwenliao_peibi"
                           data-options="width:200"></input>
                </td>
            </tr>
        </table>
        <input type="hidden" id="shuiwenliaopeibidanid" name="shuiwenliaopeibidanid" />
        <div style="text-align: center; padding: 5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" style="width: 75px" onclick="submitShuiWenLiaoPeiBiDan()" data-options="iconCls:'icon-ok'">
                保存
            </a>
            <a href="javascript:void(0)" class="easyui-linkbutton" style="width: 75px" onclick="clearShuiWenLiaoPeiBiDan()" data-options="iconCls:'icon-cancel'">
                关闭
            </a>
        </div>
    </div>
</div>
<div id="peibidan_shuiwenliao_dlg" class="easyui-dialog" title="删除确认" style="width: 300px; height: 150px;
    padding: 10px" data-options="iconCls: 'icon-help',buttons: '#peibidan_shuiwenliao-dlg-buttons',modal:true,closed:true">
    确定要删除该水稳料配比单信息吗？
</div>
<div id="peibidan_shuiwenliao-dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:delShuiWenLiaoPeiBiDan();">
        确定
    </a> <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript: $('#peibidan_shuiwenliao_dlg').dialog('close')">
        取消
    </a>
</div>




